<?php

/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/11/9
 * Time: 14:34
 */

/**
 * Class MysqliService
 * 一次数据插入
 */
class MysqliService
{

    public $db;

    public function __construct()
    {
        $this->db = mysqli_connect($host = '127.0.0.1', $user = 'root', $password = '123456', $database = 'aigaogao', $port = '3306', $socket = '');
    }

    public function close()
    {
        $this->db->close();
    }
}



$serive = new MysqliService();
/*$数组 = array(
    array(2,     14.3, 14.5, 14.9,15.1,16.3,17.7,18.1,18.6,19.0),
    array(2.5,   14.0, 14.2, 14.6,14.8,16.0,17.3,17.7,18.2,18.6),
    array(3,     13.7, 14.0, 14.3,14.5,15.7,17.0,17.3,17.9,18.2),
    array(3.5,   13.5, 13.8, 14.1,14.3,15.5,16.8,17.1,17.6,18.0),
    array(4,     13.4, 13.6, 14.0,14.2,15.3,16.7,17.0,17.6,17.9),
    array(4.5,   13.3, 13.5, 13.8,14.1,15.2,16.6,17.0,17.5,17.9),
    array(5,     13.2, 13.4, 13.8,14.0,15.2,16.7,17.0,17.6,18.1),
    array(5.5,   13.2, 13.4, 13.8,14.0,15.3,16.8,17.2,17.9,18.3),
    array(6,     13.1, 13.4, 13.7,14.0,15.3,17.0,17.4,18.1,18.6),
    array(6.5,   13.1, 13.3, 13.8,14.0,15.5,17.2,17.7,18.4,19.0),
    array(7,     13.1, 13.4, 13.8,14.1,15.6,17.5,18.0,18.8,19.4),
    array(7.5,   13.1, 13.4, 13.9,14.2,15.8,17.8,18.3,19.2,19.9),
    array(8,     13.2, 13.5, 13.9,14.3,16.0,18.1,18.7,19.7,20.4),
    array(8.5,   13.2, 13.5, 14.0,14.4,16.2,18.5,19.1,20.2,20.9),
    array(9,     13.3, 13.7, 14.2,14.6,16.4,18.9,19.5,20.7,21.5),
    array(9.5,   13.4, 13.8, 14.3,14.7,16.7,19.2,20.0,21.2,22.0),
    array(10,    13.6, 13.9, 14.5,14.9,17.0,19.6,20.4,21.7,22.6),
    array(10.5,  13.7, 14.1, 14.7,15.1,17.2,20.1,20.9,22.2,23.1),
    array(11,    13.9, 14.3, 14.9,15.3,17.5,20.5,21.3,22.7,23.6),
    array(11.5,  14.1, 14.5, 15.1,15.6,17.8,20.8,21.7,23.1,24.2),
    array(12,    14.3, 14.7, 15.3,15.8,18.1,21.2,22.1,23.6,24.6),
    array(12.5,  14.5, 14.9, 15.5,16.0,18.4,21.6,22.5,24.0,25.1),
    array(13,    14.7, 15.1, 15.7,16.2,18.7,21.9,22.9,24.4,25.5),
    array(13.5,  14.8, 15.3, 15.9,16.4,18.9,22.3,23.2,24.8,25.9),
    array(14,    15.0, 15.4, 16.1,16.7,19.2,22.6,23.5,25.1,26.3),
    array(14.5,  15.2, 15.6, 16.3,16.9,19.4,22.9,23.8,25.5,26.6),
    array(15,    15.4, 15.8, 16.5,17.1,19.7,23.1,24.1,25.8,26.9),
    array(15.5,  15.5, 16.0, 16.7,17.2,19.9,23.4,24.4,26.1,27.2),
    array(16,    15.7, 16.1, 16.9,17.4,20.1,23.6,24.7,26.3,27.5),
    array(16.5,  15.8, 16.3, 17.1,17.6,20.3,23.9,24.9,26.6,27.8),
    array(17,    16.0, 16.5, 17.2,17.8,20.5,24.1,25.1,26.8,28.0),
    array(17.5,  16.1, 16.6, 17.4,17.9,20.7,24.3,25.4,27.1,28.3),
    array(18,    16.3, 16.7, 17.5,18.1,20.8,24.5,25.6,27.3,28.5),
);*/
$arr = array(
    array(2,     13.9, 14.1, 14.5,14.8,15.9,17.3,17.7,18.2,18.6),
    array(2.5,   13.6, 13.9, 14.2,14.5,15.6,17.0,17.3,17.9,18.3),
    array(3,     13.5, 13.7, 14.0,14.3,15.4,16.8,17.1,17.7,18.0),
    array(3.5,   13.3, 13.5, 13.9,14.1,15.3,16.6,17.0,17.5,17.9),
    array(4,     13.2, 13.4, 13.7,14.0,15.2,16.5,16.9,17.5,17.8),
    array(4.5,   13.0, 13.3, 13.6,13.9,15.1,16.5,16.8,17.4,17.8),
    array(5,     12.9, 13.2, 13.5,13.8,15.0,16.5,16.8,17.5,17.9),
    array(5.5,   12.8, 13.1, 13.4,13.7,15.0,16.5,16.9,17.5,18.0),
    array(6,     12.8, 13.0, 13.4,13.7,15.0,16.5,17.0,17.6,18.1),
    array(6.5,   12.7, 13.0, 13.4,13.6,15.0,16.6,17.1,17.8,18.1),
    array(7,     12.7, 12.9, 13.3,13.6,15.0,16.7,17.2,17.9,18.2),
    array(7.5,   12.7, 12.9, 13.4,13.7,15.1,16.9,17.4,18.2,18.7),
    array(8,     12.7, 13.0, 13.4,13.7,15.2,17.1,17.6,18.5,19.0),
    array(8.5,   12.7, 13.0, 13.5,13.8,15.4,17.4,17.9,18.8,19.4),
    array(9,     12.8, 13.1, 13.6,13.9,15.6,17.7,18.3,19.2,19.9),
    array(9.5,   13.0, 13.3, 13.7,14.1,15.8,18.0,18.7,19.7,20.4),
    array(10,    13.1, 13.4, 13.9,14.3,16.1,18.4,19.1,20.1,20.9),
    array(10.5,  13.3, 13.6, 14.2,14.5,16.4,18.8,19.5,20.7,21.5),
    array(11,    13.5, 13.9, 14.4,14.8,16.7,19.3,20.0,21.2,22.0),
    array(11.5,  13.8, 14.1, 14.7,15.1,17.1,19.7,20.5,21.7,22.6),
    array(12,    14.0, 14.4, 15.0,15.4,17.4,20.2,21.0,22.3,23.2),
    array(12.5,  14.3, 14.5, 15.2,15.7,17.8,20.6,21.4,22.8,23.7),
    array(13,    14.5, 14.9, 15.5,16.0,18.1,21.1,21.9,23.2,24.2),
    array(13.5,  14.8, 15.2, 15.8,16.2,18.5,21.4,22.3,23.7,24.8),
    array(14,    15.0, 15.4, 16.0,16.5,18.8,21.8,22.7,24.1,25.1),
    array(14.5,  15.2, 15.6, 16.3,16.7,19.1,22.1,23.0,24.5,25.5),
    array(15,    15.4, 15.8, 16.5,17.0,19.3,22.4,23.3,24.8,25.9),
    array(15.5,  15.6, 16.0, 16.7,17.2,19.5,22.7,23.6,25.1,26.1),
    array(16,    15.8, 16.2, 16.8,17.3,19.7,22.9,23.8,25.3,26.4),
    array(16.5,  15.9, 16.3, 17.0,17.5,19.9,23.1,24.0,25.5,26.6),
    array(17,    16.0, 16.4, 17.1,17.6,20.0,23.3,24.2,25.7,26.8),
    array(17.5,  16.2, 16.6, 17.2,17.7,20.2,23.4,24.4,25.9,27.0),
    array(18,    16.3, 16.7, 17.4,17.9,20.3,23.6,24.5,26.1,27.2),
);
//$sex = 1;
$sex = 2;


 foreach ($arr as $key=>$val){
     $val = "$val[0],$sex,$val[1],$val[2],$val[3],$val[4],$val[5],$val[6],$val[7],$val[8],$val[9]";
     //echo $val;
     $sql = "insert into aigoo_standardbmi (age,sex,3rd,5rd,10rd,15rd,50rd,85rd,90rd,95rd,97rd) VALUE ($val)";
     $res = $serive->db->query($sql);

 }



$serive->close();
echo 'end';



